package 测试类;

import java.util.ArrayList;
import java.util.Scanner;

public class test9 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int i = scanner.nextInt();
		int t = 0;

		ArrayList<Integer> jisu = new ArrayList<>();

		for (int j = 1; j <= i ; j++) {
			t = scanner.nextInt();
			for (int k = 0; k < t; k++) {
				 if(scanner.nextInt() == 1){
				 	jisu.add(k);
				 }
			}
			System.out.println(judge(jisu));
			jisu.clear();
		}
	}

	public static int judge(ArrayList<Integer> jisu){
		int res = 0;
		int temp = 0;
		if (jisu.size() == 1){
			return 0;
		}
		for (int i = 0; i < jisu.size()-1; i++) {
			temp = jisu.get(i+1) - jisu.get(i) - 1;
			res += temp;
		}
		return res;
	}
}
